import os
import sys

# 请在此输入您的代码
'''===========================输入======================'''
# n = int(input())
# nums = list(map(int, input().split()))
# k = int(input())

n = 5 
nums = [5, 2, 7 ,4, 3 ]
k = 1 

'''=========================代码========================'''
# 对nums升序排列
up = sorted([(num, i) for i, num in enumerate(nums)])
# 脏数组
dirty = [0] * n
# 答案数组
ans = [0] * n

# 从最小值开始计算
for num, i in up:
  # 判断该最小值的区间，max(0, i - k), min(n, i + k + 1) 超过的值不计算
  for j in range(max(0, i - k), min(n, i + k + 1)):
    # 如果判断这个位置是否被计算过了
    if dirty[j] == 0:
      ans[j] = num
      dirty[j] = 1
  # 如果全部被计算过，那么结束循环
  if sum(dirty) == n:
    break

for num, i in up:
  for j in range(max(0, i - k), min(n, i + k + 1)):
    if ans[j] == 0:
      ans[j] = num
  if all(ans):
    break

'''====================输出========================'''
for i in range(n):
  if i == n - 1:
    print(ans[i])
  else:
    print(ans[i], end = ' ')